package com.itheima01;

import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;

public class Test02 {
    public static void main(String[] args) throws ClassNotFoundException, NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException {

//        Class Clazz = Class.forName("com.itheima01.Student");
//
//        Constructor constructor1 = Clazz.getConstructor();
//
//       Student student = (Student) constructor1.newInstance();
//
//        System.out.println(student);

        Class clazz2 = Class.forName("com.itheima01.Student");

        Constructor declaredConstructor = clazz2.getDeclaredConstructor(String.class);

        declaredConstructor.setAccessible(true);

        Student student1 = (Student) declaredConstructor.newInstance("zhangsan");

        System.out.println(student1);
    }
}
